//
//  feedBackNormalQuesVC.swift
//  DingDongZP
//
//  Created by 三秒文化 on 16/4/12.
//  Copyright © 2016年 iyhjiang.com. All rights reserved.
//

import UIKit

class feedBackNormalQuesVC: UITableViewController {

    var model:feedBackNormalQuesCellModel?
    let cellID = "feedBackNormalQuesCells"
    var questArr = [NSDictionary]()
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        tableView.separatorStyle = UITableViewCellSeparatorStyle.None
        tableView.translatesAutoresizingMaskIntoConstraints = false
        tableView.contentInset = UIEdgeInsetsMake(90, 0, 0, 0)
        tableView.backgroundColor = LDGolbalColor.BgGoundGray
        
        requestNet()
        
//        let marTabViewHead:UIView = UIView.init(frame: CGRectMake(0, 0, LDFrame.ScreenWidth, 15))
//        marTabViewHead.backgroundColor = UIColor.redColor()//LDGolbalColor.BgGoundGray
//        tableView.tableHeaderView?.addSubview(marTabViewHead)

    }
    
    func requestNet() {
        
        if DDClientInfoManager.clientType() == DDClientType.Cattle {
            
            LDCheckPublicInfo.shareInstance.checkoutJobfinderQuest({ [weak self] (data) in
                
                self?.questArr = data
                self?.tableView.reloadData()
            })
        } else {
            
            LDCheckPublicInfo.shareInstance.checkoutBossQuest({ [weak self] (data) in
                
                self?.questArr = data
                self?.tableView.reloadData()
            })
            
        }
    }

    // MARK: - Table view data source

    override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        // #warning Incomplete implementation, return the number of sections
        return 1
    }

    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        // #warning Incomplete implementation, return the number of rows
        return questArr.count
    }

    
    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

        
        var cell = tableView.dequeueReusableCellWithIdentifier(cellID) as? feedBackNormalQuesCell
        if cell == nil {
            cell = feedBackNormalQuesCell.init(style: UITableViewCellStyle.Default, reuseIdentifier: cellID)
        }
        cell?.model = feedBackNormalQuesCellModel.yy_modelWithDictionary(questArr[indexPath.row] as [NSObject : AnyObject])
        return cell!
    }
    override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
        
        
        model = feedBackNormalQuesCellModel.yy_modelWithDictionary(questArr[indexPath.row] as [NSObject : AnyObject])
        return (model?.height)!
    }
 
}
